package com.mlkj.serve.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.sd4324530.fastweixin.message.BaseMsg;
import com.github.sd4324530.fastweixin.message.TextMsg;
import com.github.sd4324530.fastweixin.message.req.TextReqMsg;
import com.github.sd4324530.fastweixin.servlet.WeixinControllerSupport;

/**
 * @author HanChen
 *
 */
@Controller
@RequestMapping(value="callback")
public class CallbackController extends WeixinControllerSupport{
	
	private static final Logger log = LoggerFactory.getLogger(CallbackController.class);
    private static final String TOKEN = "teamwork603";
	@Override
	protected String getToken() {
		// TODO Auto-generated method stub
		return TOKEN;
	}
	
	@Override
	  protected BaseMsg handleTextMsg(TextReqMsg msg) {
        String content = msg.getContent();
        log.info("用户发送到服务器的内容:{}", content);
        if (content.equals("1")) {
			return new TextMsg("http://servicewechat.ngrok.com/servicewechat/oauth/user");
		}else{
			return new TextMsg("I get you message");
		}
        
    }
	
}
